home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / cool / ge_cool.lha / GE_COOL2.1 / src / Date_Time / Timer.h < prev    next >
C/C++ Source or Header  |  1992-05-14  |  2KB  |  63 lines

  1. //
  2. // Copyright (C) 1991 Texas Instruments Incorporated.
  3. //
  4. // Permission is granted to any individual or institution to use, copy, modify,
  5. // and distribute this software, provided that this complete copyright and
  6. // permission notice is maintained, intact, in all copies and supporting
  7. // documentation.
  8. //
  9. // Texas Instruments Incorporated provides this software "as is" without
  10. // express or implied warranty.
  11. //
  12. //
  13. // Created: BMK 07/14/89 -- Initial design and implementation
  14. // Updated: LGO 09/23/89 -- Conform to COOL coding style
  15. // Updated: AFM 12/31/89 -- OS/2 port
  16. // Updated: DLS 03/22/91 -- New lite version
  17. //
  18. // The Timer class provides timing code  for performance evaluation.  This code
  19. // was originally written by Joe Rahmeh at UT Austin.
  20. //
  21.  
  22. #include <sys/types.h>
  23.  
  24. #if defined(DOS)
  25. extern "C" {
  26. #include <sys/timeb.h>
  27. #include <time.h>
  28. }
  29. #else
  30. #include <sys/timeb.h>
  31. #include <sys/time.h>
  32. #include <sys/resource.h>
  33. /* extern int getrusage (int, rusage *);
  34. extern int ftime (timeb *);
  35. */
  36. #endif
  37.  
  38.  
  39. class CoolTimer {
  40. public:
  41.   CoolTimer () {mark();}    // constructor
  42.   
  43.   void mark ();        // mark timer
  44.   
  45.   long user ();        // user        time (ms) since last Mark
  46.   long system ();    // system      time (ms) since last Mark
  47.   long all ();        // user+system time (ms) since last Mark
  48.   long real ();        // real        time (ms) since last Mark
  49.   
  50.   long user_usec ();    // user        time (us) since last Mark
  51.   long system_usec ();    // system      time (us) since last Mark
  52.   long all_usec ();    // user+system time (us) since last Mark
  53.  
  54. private:
  55. #if defined(DOS) || defined(MSDOS)
  56.   clock_t usage0;
  57. #else
  58.   rusage  usage0;    // rusage structure at last mark
  59. #endif
  60.   timeb   real0;    // elapsed real time at last mark
  61. };
  62.  
  63.